package com.test.mooan.labama.activity_fragment_boom.fragment_boom;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.test.mooan.labama.activity_fragment_boom.base_boom.BaseFragment_boom;
import com.test.mooan.labama.bean_boom.config_info_boom.CountryInfo_boom;
import com.test.mooan.labama.R;


public class DataSafetyFragment_boom extends BaseFragment_boom {

    private WebView webView_boom;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_data_safety_boom, container, false);
        webView_boom = view.findViewById(R.id.fragment_data_safety_web_view);
        pageTag = "STATEMENT";
        init_boom();
        return view;
    }

    @SuppressLint("SetJavaScriptEnabled")
    private void init_boom() {

        //初始化配置
        webView_boom.setInitialScale(100);
        webView_boom.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return shouldOverrideUrlLoading(view, request.getUrl().toString());
            }
        });

        WebSettings settings = webView_boom.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setTextZoom(100);
        settings.setSupportZoom(true);
        settings.setUseWideViewPort(true);
        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setBuiltInZoomControls(true);
        settings.setLoadWithOverviewMode(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            settings.setAllowUniversalAccessFromFileURLs(true);
            settings.setAllowFileAccessFromFileURLs(true);
            settings.setAllowContentAccess(true);
        }

        webView_boom.loadUrl(CountryInfo_boom.gInstance().gPrivacyPolicyUrl());

    }

}